//
//  MCBasicViewController.m
//  MCPublicModule
//
//  Created by Mirko on 15/12/29.
//  Copyright (c) 2015年 Mirko. All rights reserved.
//

#import "MCBasicViewController.h"
#import "MCUtils.h"
#import "MCUIButton.h"
#import "Masonry.h"
#import "MCBasicViewController+NavigationBar.h"



@interface MCBasicViewController ()

@end

@implementation MCBasicViewController

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (id)init {
    if (self = [super init]) {
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.cellLineNoSpace = NO;
    self.pageIdex = 0;
    self.pageStep = 10;
    self.currentPage = 0;
    
    self.mcTableDataSource = [[NSMutableArray alloc] init];
}

- (void) setTitle:(NSString *)title
{
    [self.titleButton setTitle:title forState:UIControlStateNormal];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(void) handleGoBackEvent:(UIButton *) sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void) handleNavigationAction:(EMCNavigationActionType) actionType;
{
    if (actionType == kMCNavActionLeftAreaLeft) {
        [self handleGoBackEvent:self.leftAreaLBtn];
    }
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark about param
-(BOOL) parameterIsValid
{
    if (self.parameter && [self.parameter isKindOfClass:[NSDictionary class]] &&self.parameter.count != 0 ) {
        return YES;
    }
    return NO;
}

@end


#pragma mark extend loadIb

@implementation MCBasicViewController (LoadIB)

+(instancetype) loadIBVCIdentifier:(NSString *) name
{
    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:NSStringFromClass([self class]) bundle:nil];
    MCBasicViewController *result = nil;
    if (name && name.length != 0) {
        result = [storyBoard instantiateViewControllerWithIdentifier:name];
    }
    else
    {
        result = [storyBoard instantiateInitialViewController];
    }
    return result;
}

+(instancetype) loadMCIBVCIdentifier:(NSString *) name
{
    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:NSStringFromClass([self class]) bundle:[MCUtils MCPMBundle]];
    MCBasicViewController *result = nil;
    if (name && name.length != 0) {
        result = [storyBoard instantiateViewControllerWithIdentifier:name];
    }
    else
    {
        result = [storyBoard instantiateInitialViewController];
    }
    return result;
}

@end
